/**
    Copyright (C) 2012 Guido Ludwig

    This file is part of JATT.
	http://code.google.com/p/jatt/

    JATT is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.guidoludwig.jatt.chain.commands.config;

import java.util.Comparator;

import de.guidoludwig.jatt.util.ImageInfo;
import de.guidoludwig.jatt.util.ImageInfoComparator;

/**
 * @author Guido Ludwig
 */
public class SelectOptimizedImageConfig extends JATTCommandConfigBase {

	private static final long serialVersionUID = -3414746791525402282L;

	public static final String PROPERTY_WIDTH = "width";
	public static final String PROPERTY_SIZE = "size";
	public static final String PROPERTY_BACKUP = "backup";

	private int width;
	private long size;
    private boolean backup;

	public SelectOptimizedImageConfig() {
		width = 500;
		size = 50000;
		backup = true;
	}

	@Override
	public String getTitle() {
		return "Select optimized Image";
	}

	@Override
	public String getDescription() {
		return "Selects and / or optimizes the Folder Image as per configuration";
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int newWidth) {
		int old = width;
		this.width = newWidth;
		firePropertyChange(PROPERTY_WIDTH, old, width);
	}
	public long getSize() {
		return size;
	}

	public void setSize(long newSize) {
		long old = size;
		this.size = newSize;
		firePropertyChange(PROPERTY_SIZE, old, size);
	}

    public boolean isBackup() {
        return backup;
    }

    public void setBackup(boolean newBackup) {
        boolean oldActive = isBackup();
        backup = newBackup;
        firePropertyChange(PROPERTY_BACKUP, oldActive, backup);
    }

    public Comparator<ImageInfo> getComparator() {
    	return new ImageInfoComparator(width, size);
    }


}
